package main

import (
	_ "main/packageDemo"
)

func main() {

	ContextMain()

	//FetchUrlDemo1()

	//FetchUrlDemo()

	//RecoverGoroutinePanic()

	//atomicMain()

	//syncMapMain()

	//syncOnceMain()

	//channelMain()
	//defineChannelType()

	//runtime.GOMAXPROCS(1)
	//go a()
	//go b()
	//time.Sleep(time.Second)

	//waitGroup := &sync.WaitGroup{}
	//
	//waitGroup.Add(2)
	//go worker(1, waitGroup)
	//go worker(2, waitGroup)
	//waitGroup.Wait()

	//go goroutineDemo1()
	//fmt.Println("main goroutine done！")
	//time.Sleep(time.Second)

	//pointerDemo()

	//var age interface{} = 19
	//fmt.Printf("%T\n", age) // int
	//age = "111"
	//fmt.Printf("%T\n", age) // string
	//age = true
	//fmt.Printf("%T\n", age) //bool

	//反射：
	//reflectDemo()
	//reflectWritable()
	//reflectKind()
	//reflectTypeConversion(reflect.ValueOf(1))    // Type:int64，Value:1
	//reflectTypeConversion(reflect.ValueOf(1.2))  // Type:float64，Value:1.2
	//reflectTypeConversion(reflect.ValueOf(true)) //Type:bool，Value:true
	//var name string = "安全了"
	//reflectTypeConversion(reflect.ValueOf(name)) // Type:bool，Value:true
	//reflectTypeConversion(reflect.ValueOf(&name)) // Type:uintptr，Value:824634040880
	//var age interface{} = 1
	//reflectTypeConversion(reflect.ValueOf(age)) // Type:int64，Value:1
	//reflectSlice()
	//reflectStruct()

	//printType("啊啊啊啊")
	//printType(111)

	//fmt.Println(getDataType(19))     // int
	//fmt.Println(getDataType("天下大同")) // string
	//fmt.Println(getDataType(true))   // 未知类型

	//show("鸳鸯戏水") // type:string value:鸳鸯戏水
	//show(18) // type:int value:18
	//
	//m := make(map[interface{}]interface{})
	//m[18]="年龄"
	//m["年龄"]=18
	//for i, i2 := range m {
	//	fmt.Printf("type:%T value:%v",i,i)
	//	fmt.Printf("type:%T value:%v",i2,i2)
	//	fmt.Println()
	//}
	//type:string value:年龄type:int value:18
	//type:int value:18type:string value:年龄

	//var x interface{}
	//str := "我在景德镇等你"
	//x = str
	//fmt.Printf("type:%T value:%v\n", x, x) // type:string value:我在景德镇等你

	//var dog animal = dog{}
	//dog.say() // 汪汪汪
	//dog.move() // 狗会动

	//var haier WashingMachine = haier{dryer{}}
	//haier.wash() //洗刷刷
	//haier.dry() // 甩一甩

	//var d_s sayer = dog{}
	//d_s.say() // 汪汪汪
	//var d_m Mover = dog{}
	//d_m.move() // 狗会动

	//var peo People = Student{}
	//think := "bitch"
	//fmt.Println(peo.Speak(think))

	//值接收者
	//var mover Mover
	//wangcai := dog{}
	//mover = wangcai
	//fugui := &dog{}
	//mover = fugui
	//mover.move() //汪汪汪

	//指针接收者
	//c1 := cat{}
	//mover = c1 //编译报错
	//c2 := &cat{}
	//mover = c2
	//mover.move()

	//var s sayer
	//c := cat{}
	//d := dog{}
	//s = c
	//s.say()
	//s = d
	//s.say()

	//A()
	//B()
	//C()

	//test()

	//x := 1
	//y := 2
	//defer calc("AA", x, calc("A", x, y))
	//x = 10
	//defer calc("BB", x, calc("B", x, y) )
	//y = 20
	//A 1 2 3
	//B 10 2 12
	//BB 10 12 22
	//AA 1 3 4

	//fmt.Println(f1())  //5
	//fmt.Println(f2())  //6
	//fmt.Println(f3())  //5
	//fmt.Println(f4())  //5

	//deferDemo()

	//调用入参为匿名函数类型的函数
	//test := Test(func() int {
	//	return 1
	//})
	//fmt.Println(test) // 1

	//调用入参为函数类型的函数
	//format := Format(func(s string, x, y int) string {
	//	return fmt.Sprintf(s, x, y)
	//}, "%d %d", 1, 2)
	//fmt.Println(format) // 1 2

	//fmt.Println(ParamsShortening(1, 2, 3))
	//_, sum := IndefiniteParameters(6, 5, 3, 4, 2, 1)
	//fmt.Println(sum) // 10
	//_, sum = IndefiniteParameters(6)
	//fmt.Println(sum) // 0

	//resp2, r := FuncResp2()
	//fmt.Println(resp2, r) // 1 2
	//resp1, s := FuncResp1()
	//fmt.Println(resp1, s) // 1 A
	//resp3 := FuncResp3()
	//fmt.Println(resp3) // []

	//fmt.Println(variable1) // 1
	//Variable()

	//由于Add、Sub 都有满足 Calculation 函数类型，即Add、Sub 可以用该类型声明赋值
	//var calculation Calculation = Add
	//i := calculation(1, 2)
	//fmt.Println(i) // 3
	//calculation = Sub
	//i2 := calculation(2, 1)
	//fmt.Println(i2) // 1

	//add, sub := Calc(3, 2, Add, Sub)
	//fmt.Println(add, sub) // 5 1

	//executeFunc, f := ExecuteFunc()
	//i := executeFunc(1, 2) // -1
	//i1 := f(1, 2)          // 3
	//fmt.Println(i, i1)

	//f := func(x, y int) int {
	//	return x + y
	//}
	//fmt.Println(f(1,2)) // 3
	//
	//i := func(x, y int) int {
	//	return x + y
	//}(1, 3)
	//fmt.Println(i) // 4

}
